package com.woniuxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.woniuxy.ResponseResult;
import com.woniuxy.entity.Store;
import com.woniuxy.mapper.StoreMapper;
import com.woniuxy.service.StoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2021-03-23
 */
@Service
@SuppressWarnings("all")
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {
    @Autowired
    private StoreMapper storeMapper;
    @Override
    public ResponseResult<Map<String, Object>> getStoreById(Integer storeId) {
        QueryWrapper<Store> queryWrapper = new QueryWrapper<>();
//        创造查询条件
        queryWrapper.eq("id",storeId);
        ResponseResult result = new ResponseResult();
        int count = storeMapper.selectCount(queryWrapper);
        if(count==0){
                result.setCode(100);
                result.setMsg("无此店铺");
                return result;

        }
        List<Map<String, Object>> maps = storeMapper.selectMaps(queryWrapper);
        result.setData(maps.get(0));
        return result;
    }

    @Override
    public ResponseResult<List<Map<String, Object>>> getStoreByIds(List<Integer> ids) {
        List<Map<String, Object>> list = storeMapper.getList(ids);
        ResponseResult<List<Map<String, Object>>> responseResult= new ResponseResult<>();
        responseResult.setCode(200);
        responseResult.setMsg("查询成功");
        responseResult.setData(list);
        return responseResult;
    }


}
